package cn.test;

/**
 * @author oldliu
 * @since 1.0
 */
public class ShuzuResort {
    public static void main(String[] args) {
        int []ar={5,4,3,2,1,0,-1,-2,-4,9};

        for (int i = 0; i < ar.length; i++) {
            //假定两边都成立
            boolean left=true;
            boolean right=true;
            //ar[i]是当前值
            //看左边，有没有不满足
            //0 到 i-1
            for(int j=0;j<=i-1;j++){
                if(ar[j]>ar[i]){
                    left=false;
                    break;
                }
            }
            //看右边，有没有不满足
            //i+1 到 ar.length-1
            for(int j=i+1;j<=ar.length-1;j++){
                if(ar[j]<ar[i]){
                    right=false;
                    break;
                }
            }
            if(left&&right){
                System.out.println(ar[i]+"。位置在："+i);
                return;
            }
        }
        System.out.println("没有满足条件的数");
    }
}
